function defineReactive(data, key, value) {
    Object.defineProperty(data, key, {
        enumerable: true,//可枚举
        configurable: false,//可改变描述符
        get: function defineGet() {
            console.log(`get key: ${key} value: ${value}`)
            return value
        },
        set: function defineSet(newVal) {
            console.log(`set key: ${key} value: ${newVal}`)
            value = newVal
        }
    })
}
/**
 * 循环数组的每一项来监听
 * @param {array} data 
 */
function observe(data) {
    Object.keys(data).forEach(function (key) {
        defineReactive(data, key, data[key])
    })
}

let arr = [1, 2, 3]
observe(arr)